import { createRouter, createWebHistory, } from 'vue-router'
import Layout from "@/layout/index.vue"
import Login from '@/views/main-app/Login.vue'
import NotFound from '@/views/404.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "/:catchAll(.*)",
      redirect: "/404"
    },
    {
      path: '/404',
      name: 'not-found',
      component: NotFound
    },
    {
      path: '/login',
      name: 'login',
      component: Login
    },
    {
      path: '/',
      redirect: "/sub-app/home",
    },
    {
      path: '/sub-app',
      component: Layout,
      children: [
        {
          path: '/sub-app/home',
          name: 'home',
          component: () => import('../views/sub-app/HomeApp.vue')
        },
        {
          path: '/sub-app/about',
          name: 'about',
          component: () => import('../views/sub-app/AboutApp.vue')
        },
        {
          path: '/sub-app/job',
          name: 'job',
          component: () => import('../views/sub-app/JobApp.vue')
        },
        {
          path: '/sub-app/enterprise',
          name: 'enterprise',
          component: () => import('../views/sub-app/EnterpriseApp.vue')
        }
      ]
    },
  ]
})

export default router
